/*
 
 * 首页js代码

*/

/*------------------头部隐藏区域-----------------------*/
$(document).scroll(function(){
	if($(document).scrollTop()>60){
		$("#top-hide").stop().animate({"top":0})
	}else{
		$("#top-hide").stop().animate({"top":"-80px"})
	}
});
/*------------------点击图片消失----------------------------------*/


$("#mei").bind("click",function(){

	$("#top>.active_img").css({"display":"none"});
});

/*------------------top-nav-上鼠标指上有列表-------（面向对象指针）--hover事件------------*/
function hidelist(obj){
	this.obj = obj;
	this.pp =this.obj.children().eq(0).find("span");
	this.second = this.obj.children().eq(1);
	this.init();
}

hidelist.prototype={
	init:function(){
		this.menu();
	},
	menu:function(){
		var that=this;
	 this.obj.hover(function(){
		 // console.log(2)
		that.obj.children().eq(1).css("display","block");
		that.obj.css({
			"background":"#fff",
			"borderColor":"#e2e2e2"
		});
		that.obj.children().eq(0).css("color","#cd1c1c")
	},function(){
		that.obj.children().eq(1).css("display","none");
		that.obj.css({
			"background":"#f7f7f7",
			"borderColor":"#f7f7f7"
		})
		that.obj.children().eq(0).css("color","#666")
	})
	}
	
}
new hidelist($(".a_div_1"));
new hidelist($(".a_div_2"));
new hidelist($(".a_div_3"));
new hidelist($(".a_div_4"));
new hidelist($(".web"));
/*
function webSecond(obj){
	// console.log($(this))
	this.dom = $(obj);
	this.second = this.dom.children().eq(1);
	this.direc = this.dom.children().eq(0).find("span") ;
	this.init();
}


webSecond.prototype.init = function(){
	// console.log(1)
	this.showMenu();
 	this.changeBackground();
 	this.changePic();
}
webSecond.prototype.changePic =function(){
	var that = this;
	this.dom.hover(function(){
		that.direc.css("backgroundPosition","0 -4px")
	},function(){
		that.direc.css("backgroundPosition","0 0")
	})
}
webSecond.prototype.showMenu = function(){
	// console.log(1)
	var that = this;
	 this.dom.hover(function(){
		 // console.log(2)
		that.dom.children().eq(1).css("display","block");
		that.dom.css({
			"background":"#fff",
			"borderColor":"#e2e2e2"
		});
		that.dom.children().eq(0).css("color","#cd1c1c")
	},function(){
		that.dom.children().eq(1).css("display","none");
		that.dom.css({
			"background":"#f7f7f7",
			"borderColor":"#f7f7f7"
		})
		that.dom.children().eq(0).css("color","#666")
	})
	 
}
webSecond.prototype.changeBackground =function(){
	this.second.find("a").hover(
		function(){
			$(this).css({
				"background":"#ddd"
			})  
		},function(){
			$(this).css({
				"background":"#fff"
			})
		});

}
new webSecond(".a_div_1");
*/
//----------轮播图--------------
move();
function move(){
		var div=document.getElementsByClassName("ban")[0];
		var ul=div.getElementsByTagName("ul")[0];
		var ol=div.getElementsByTagName("ol")[0];
		var lis=Array.from(ol.children);
		var ul_li=Array.from(ul.children);
		var prev1=document.getElementById("prev1");
		var next1=document.getElementById("next1");
		lis.forEach(function(li,ind){
			li.onmouseover=function(){
				
				num=ind;//将下标赋给全局变量
				tab();//执行运动代码
				//console.log(num);
			}
		});
		var num=0;
		lis[num].children[0].className="active";
		
		ul_li[num].style.zIndex=1;
		//点击右下角运动
		function tab(){
			//设置按钮样式  透明度运动
			lis.forEach(function(li,ind){
				li.children[0].className="";
				li.children[0].style.width="";
				startMove(ul_li[ind],{"opacity":0},function(){
					ul_li[ind].style.display="none";
				});
			});
			lis[num].children[0].className="active";
			lis[num].children[0].style.width=30+"px";
			
			ul_li[num].style.display="block";
			startMove(ul_li[num],{"opacity":100});
		}
		//自行运动（向右）
		function next(){
				num++;
				if(num==6){
					num=0;
				}
				tab();
		}
		//自行运动（向左）
		function prev(){
				num--;
				if(num==-1){
					num=5;
				}
				tab();
		}
		var timer=setInterval(next,2000);
		//鼠标移入移出效果
		div.onmouseover=function(){
			clearInterval(timer);
		}
		div.onmouseout=function(){
			timer=setInterval(next,3000);
		}
		//向右
		next1.onclick=next;
		//向左
		prev1.onclick=prev;
}

$("#bannerwrapcenter").bind("mouseenter",function(){
	$("#prev1").stop().animate({"left":0});
	$("#next1").stop().animate({"right":0})
});
$("#bannerwrapcenter").bind("mouseleave",function(){
	$("#prev1").stop().animate({"left":-40});
	$("#next1").stop().animate({"right":-40})
});
//--------轮播题左边的大列表-==============




$("#banner .banner-wrap-left ul .m1").bind("mouseenter",function(){
	$("#banner .banner-wrap-left ul .m1 .list1").stop().fadeIn();
	//$("#banner .banner-wrap-left ul .m1 .list1").css({"display":"block"},200);
});
$("#banner .banner-wrap-left ul .m1").bind("mouseleave",function(){
	$("#banner .banner-wrap-left .list1").stop().fadeOut();
	//$("#banner .banner-wrap-left ul .m1 .list1").css({"display":"none"},200);
})
/////------------------
$("#banner .banner-wrap-left ul .m2").bind("mouseenter",function(){
	$("#banner .banner-wrap-left ul .m2 .list2").stop().animate({"opacity":1},200);
	$("#banner .banner-wrap-left ul .m2 .list2").css({"display":"block"},200);
});
$("#banner .banner-wrap-left ul .m2").bind("mouseleave",function(){
	$("#banner .banner-wrap-left .list2").stop().animate({"opacity":0},200);
	$("#banner .banner-wrap-left ul .m2 .list2").css({"display":"none"},200);
});
/////------------------
$("#banner .banner-wrap-left ul .m3").bind("mouseenter",function(){
	$("#banner .banner-wrap-left ul .m3 .list3").stop().animate({"opacity":1},200);
	$("#banner .banner-wrap-left ul .m3 .list3").css({"display":"block"},200);
});
$("#banner .banner-wrap-left ul .m3").bind("mouseleave",function(){
	$("#banner .banner-wrap-left .list3").stop().animate({"opacity":0},200);
	$("#banner .banner-wrap-left ul .m3 .list3").css({"display":"none"},200);
});
